package com.kycxika.app.activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.view.View;
import com.kycxika.app.R;
import com.kycxika.app.activity.base.BaseActivity;
import com.kycxika.app.activity.twoactivity.HomeTwoActivity;
import com.kycxika.app.activity.twoactivity.MeActivity;
import com.kycxika.app.bean.MaqureeBean;
import com.kycxika.app.view.VerticalTextview;

import java.util.ArrayList;

public class MainTwoActivity extends BaseActivity {

    private View mTop;
    private VerticalTextview maquree_txt;

    @Override
    protected void initView() {
        mTop = findViewById(R.id.top);
        setTop(mTop);
        getVisibility(false,MainTwoActivity.this);
        getTitle("点我");

        maquree_txt = (VerticalTextview) findViewById(R.id.maquree_txt);

    }

    @Override
    protected void initData() {
     /*   ArrayList<String> mlist = new ArrayList<>();
        mlist.add("我是一个上下滚动的通知.");
        mlist.add("新年到了,这里有最新鲜的年货.");
        mlist.add("世纪新款棉衣,戳进来!");
        mlist.add("复古风棉衣,让你过年美美哒!!");
        maquree_txt.setTextList(mlist);*/
        ArrayList<MaqureeBean> mlist = new ArrayList<>();
        mlist.add(new MaqureeBean("我是一个上下滚动的通知.",R.drawable.family_school_press));
        mlist.add(new MaqureeBean("世纪新款棉衣,戳进来!",R.drawable.home_press));
        mlist.add(new MaqureeBean("新年到了,这里有最新鲜的年货.",R.drawable.boke_h));
        mlist.add(new MaqureeBean("复古风棉衣,让你过年美美哒!!",R.drawable.video_h));

        maquree_txt.setTextList(mlist);
        maquree_txt.setText(15, 5, getResources().getColor(R.color.c_f97885));//设置属性,具体跟踪源码
        maquree_txt.setTextStillTime(3000);//设置停留时长间隔
        maquree_txt.setAnimTime(300);//设置进入和退出的时间间隔
        //对单条文字的点击监听
        maquree_txt.setOnItemClickListener(new VerticalTextview.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                // TO DO
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        maquree_txt.startAutoScroll();
    }

    @Override
    protected void onPause() {
        super.onPause();
        maquree_txt.stopAutoScroll();
    }

    @Override
    protected void initListener() {
        findViewById(R.id.me_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainTwoActivity.this, MeActivity.class));
            }
        });

        findViewById(R.id.home_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainTwoActivity.this, HomeTwoActivity.class));
            }
        });

        findViewById(R.id.video_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        findViewById(R.id.blog_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    @Override
    public int getLayout() {
        return R.layout.activity_main_two;
    }

    @Override
    public void onBackPressed() {
        new AlertDialog.Builder(this)
                .setCancelable(true)
                .setTitle("系统退出")
                .setMessage("确定退出当前程序吗?")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        MainTwoActivity.this.finish();

                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).show();
    }
}
